#include "jcode.h"
#include <QPainter>
#include <QtDebug>
#include <QDir>
#include <QDirIterator>
#include <QJsonObject>
#include <QJsonDocument>
#include <QApplication>
#include <QClipboard>
#include <QMessageBox>
#include <QNetworkInterface>
#include <QHostInfo>
#include <QNetworkAccessManager>
#include <QObject>


QString JCode::getUrl(const QString Url)
{
   QUrl url(Url);
   QNetworkAccessManager manager;
   QEventLoop loop;

   // qDebug() << "图片下载地址： " << GifUrl;
   QNetworkReply *reply = manager.get(QNetworkRequest(url));
   //请求结束并下载完成后，退出子事件循环
   QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
   //开启子事件循环
   loop.exec();
   QByteArray FileMsg = reply->readAll();
   QString curPath= QCoreApplication::applicationDirPath();//获取当前目录
   QString FileName = QString("%1/tmp.url").arg(curPath);
       QFile file(FileName);
       //if (file.exists()){
       //    file.remove();
       //}

       if(!file.open(QFile::WriteOnly))
       {
           qDebug() << "open file fail";
           exit(1);
       }
       file.write(FileMsg);
       file.close();
   return FileName;
}
QString JCode::getUrlString(const QString Url)
{
   QUrl url(Url);
   QNetworkAccessManager manager;
   QEventLoop loop;

   // qDebug() << "图片下载地址： " << GifUrl;
   QNetworkReply *reply = manager.get(QNetworkRequest(url));
   //请求结束并下载完成后，退出子事件循环
   QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
   //开启子事件循环
   loop.exec();
   QByteArray FileMsg = reply->readAll();
   QString str = QString(FileMsg);
   return str;
}

QString JCode::CMD(QString commandStr)  //执行CMD命令
{
     QProcess cmd;	//类似于window里面的cmd命令
     QTextCodec *codec = QTextCodec::codecForName("GBK");
     QString outstr;
         cmd.start(commandStr);	//ping ip地址 -n 1表示只ping一次就结束
         cmd.waitForFinished(-1);			//等待ping完成
         outstr = codec->toUnicode(cmd.readAll());	//将ping之后的结果全部读到outstr中
    //QMessageBox::information(NULL, "信息", outstr);
    return outstr;
}

QString JCode::PingIP(QString IP)  //Ping IP地址
{
     bool m_state=false;
     QString str="失败";
     QProcess cmd;	//类似于window里面的cmd命令
     QTextCodec *codec = QTextCodec::codecForName("GBK");
     QString outstr;
         cmd.start("ping "+IP + " -n 1");	//ping ip地址 -n 1表示只ping一次就结束
         cmd.waitForFinished(-1);			//等待ping完成
         outstr = codec->toUnicode(cmd.readAll());	//将ping之后的结果全部读到outstr中
         if(-1!=outstr.indexOf("往返行程的估计时间"))	//通过判断有无“往返行程的估计时间”这几个字来检测网路是否通
         {
             if(!m_state)	//通过m_state变量使网络无论在通或不通只发送一次信号
             {
                 str="成功";
             }
         }
         else
         {
             if(m_state)
             {
                 str="失败";
             }
         }
    return str;
}
QString JCode::SYSINFO(){ //获取操作系统信息
    QString str="";
    str+=QString("WindowsVersion:%1\n").arg(QSysInfo::WindowsVersion);
    str+=QString("buildAbi:%1\n").arg(QSysInfo::buildAbi());
    str+=QString("buildCpuArchitecture:%1\n").arg(QSysInfo::buildCpuArchitecture());
    str+=QString("currentCpuArchitecture:%1\n").arg(QSysInfo::currentCpuArchitecture());
    str+=QString("kernelType:%1\n").arg(QSysInfo::kernelType());
    str+=QString("kernelVersion:%1\n").arg(QSysInfo::kernelVersion());
    str+=QString("machineHostName:%1\n").arg(QSysInfo::machineHostName());
    str+=QString("prettyProductName:%1\n").arg(QSysInfo::prettyProductName());
    str+=QString("productType:%1\n").arg(QSysInfo::productType());
    str+=QString("productVersion:%1\n").arg(QSysInfo::productVersion());
    str+=QString("Windows Version:%1\n").arg(QSysInfo::windowsVersion());

    return str;
}
QString JCode::GetIPadd(){ //获取IP地址
    QString localHostName = QHostInfo::localHostName();
    QString tmp="";
    tmp+= QString("主机名:%1\n").arg(localHostName);
    QHostInfo info = QHostInfo::fromName(localHostName);
    foreach(QHostAddress address,info.addresses())
    {
        if(address.protocol() == QAbstractSocket::IPv4Protocol)
            tmp+= QString("IP地址:%1\n").arg(address.toString());
    }
    return tmp;

}
QString JCode::GetMACadd(){
    QString address;
      auto interfaces = QNetworkInterface::allInterfaces();

      for (int i = 0; i < interfaces.length(); i++) {
          if (interfaces[i].isValid()) {
              address = interfaces[i].hardwareAddress();
              break;
          }
      }

      if (address.isEmpty()) {
          address="ff:";
      }
    return address;
}


bool JCode::TableWidgetTOPDF(const QTableWidget *tableWidget, QString PDFFileName,QString Title,QString Title1,QString PageEnd,QString PageOrientation )
{ //TableWidget  转PDF文件
    QString fileName=PDFFileName;
    QFile pdfFile(fileName);
    if (pdfFile.exists()){
        pdfFile.remove();
    }
    pdfFile.open(QIODevice::WriteOnly);                 // 打开要写入的pdf文件
    QPdfWriter* pPdfWriter = new QPdfWriter(&pdfFile);  // 创建pdf写入器
    pPdfWriter->setPageSize(QPagedPaintDevice::A4);     // 设置纸张为A4
    if (PageOrientation=="横向"){
        pPdfWriter->setPageOrientation(QPageLayout::Landscape);
    }
    //pPdfWriter->setPageOrientation(QPageLayout::Orientation);
    pPdfWriter->setResolution(300);                     // 设置纸张的分辨率为300,因此其像素为3508X2479

    pPdfWriter->setTitle(Title);
    int iMargin = 30;                   // 页边距
    pPdfWriter->setPageMargins(QMarginsF(iMargin+20, iMargin, iMargin+10, iMargin)); //左上右下页边距
    QPainter* pPdfPainter = new QPainter(pPdfWriter);   // qt绘制工具
    // 标题,居中
    QTextOption option(Qt::AlignHCenter | Qt::AlignVCenter);
    option.setWrapMode(QTextOption::WordWrap); //字段太长自动换行
    // iTop 标题上边留白数字
    int iTop = 0;
    int lineheihgt=100; //行高
    int PageNo=1;
    int rows=tableWidget->rowCount(); //取总行数
    int cols=tableWidget->columnCount(); //取总列数
    int PageCount=0;
    PageCount=rows/30;
    if (PageCount*30<rows){
        PageCount++;
    }
    if (PageOrientation=="横向"){
        PageCount=rows/19;
        if (PageCount*19<rows){
            PageCount++;
        }
    }
    // 文本宽度 去除页边距后盛满
    int iContentWidth = pPdfWriter->width();
    int iContentheight = pPdfWriter->height();

    //加载图片
    //QPixmap image1;
    //image1.load(":/icon/res/zclo.png");
    //pPdfPainter->drawPixmap(0,0,100,100,image1);
    // 标题,18号字
    QFont font;
    //font.setFamily("simhei.ttf");
    font.setFamily("新宋体");
    int fontSize = 18;

    font.setPointSize(fontSize);
    pPdfPainter->setFont(font);                    // 为绘制工具设置字体
    QString str="";
    str=Title;
    pPdfPainter->drawText(QRect(0, iTop, iContentWidth, 90),str, option); //打印标题
    iTop += 90;
    str=Title1; //副标题
    fontSize = 7;
    font.setPointSize(fontSize);
    pPdfPainter->setFont(font);
    QTextOption ita; //ita为单元格的对齐方式
    ita.setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    pPdfPainter->drawText(QRect(0, iTop, iContentWidth, 45),str, ita); //打印副标题
    iTop += 50;
    QTextOption detailoption(Qt::AlignVCenter);
    detailoption.setWrapMode(QTextOption::WordWrap);
    //int colwidth=pPdfWriter->width()/cols;
    double totWidth=pPdfWriter->width();
    double totCOL=0; //tableWidget总列宽
    for(int j=0; j<cols; j++){
        totCOL+=tableWidget->columnWidth(j);
    }
    double ColBL=totWidth/totCOL;
    //获取表头
    pPdfPainter->setRenderHint(QPainter::Antialiasing, true);
    // 设置画笔颜色
    pPdfPainter->setPen(QPen(Qt::black, 2)); //设置颜色和粗细
    // 绘制直线
    pPdfPainter->drawLine(QPointF(0, iTop), QPointF(pPdfWriter->width(), iTop)); //表格横线
    pPdfPainter->drawLine(QPointF(0, iTop), QPointF(0, iTop+lineheihgt) );//第一根竖线
    pPdfPainter->drawLine(QPointF(pPdfWriter->width(), iTop), QPointF(pPdfWriter->width(), iTop+lineheihgt) );//最后一根竖线
    //列出表头
    totCOL=0;
    for(int j=0; j<cols; j++){
        QTextOption ita; //ita为单元格的对齐方式
        ita.setAlignment(Qt::AlignCenter | Qt::AlignVCenter);
        ita.setWrapMode(QTextOption::WordWrap);
        pPdfPainter->drawText(QRect(totCOL-2, iTop, tableWidget->columnWidth(j)*ColBL-2, lineheihgt),tableWidget->horizontalHeaderItem(j)->text(),ita);
        pPdfPainter->drawLine(QPointF(totCOL, iTop), QPointF(totCOL, iTop+lineheihgt) );//竖线
        totCOL+=tableWidget->columnWidth(j)*ColBL;
        if (totWidth<totCOL){
            totCOL=totWidth;
        }
    }
    iTop+=lineheihgt;
    //列出明细
        for(int i=0; i<rows; i++) // 取出每个格子的内容
        {
            pPdfPainter->setRenderHint(QPainter::Antialiasing, true);  // 反走样
            pPdfPainter->setPen(QPen(Qt::black, 2)); //设置颜色和粗细
            pPdfPainter->drawLine(QPointF(0, iTop), QPointF(pPdfWriter->width(), iTop) ); //表格横线
            pPdfPainter->drawLine(QPointF(0, iTop), QPointF(0, iTop+lineheihgt) );//第一根竖线
            pPdfPainter->drawLine(QPointF(pPdfWriter->width(), iTop), QPointF(pPdfWriter->width(), iTop+lineheihgt) );//最后一根竖线
            totCOL=0;
            for(int j=0; j<cols; j++){

                QTextOption ita; //ita为单元格的对齐方式
                ita.setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
                //QString  tmp1=QString ("111： %1").arg(tableWidget->item(i,j)->textAlignment());
                //qDebug()<< tmp1;
                //ita.setAlignment(tmp1);
                str=tableWidget->horizontalHeaderItem(j)->text();
                if(str.contains("额",Qt::CaseSensitive) || str.contains("币",Qt::CaseSensitive)){ //ui->tableWidget1->item(i,j)->textAlignment()==Qt::AlignRight
                   ita.setAlignment(Qt::AlignRight | Qt::AlignVCenter );
                }
                ita.setWrapMode(QTextOption::WordWrap);
                str="";
                if(tableWidget->item(i,j) != NULL){//一定要先判断非空，否则会报错
                    str=tableWidget->item(i,j)->text();
                }
                pPdfPainter->drawText(QRect(totCOL+2, iTop, tableWidget->columnWidth(j)*ColBL-2,lineheihgt),str,ita);
                pPdfPainter->drawLine(QPointF(totCOL, iTop), QPointF(totCOL, iTop+lineheihgt) );//竖线
                totCOL+=tableWidget->columnWidth(j)*ColBL;
                if (totWidth<totCOL){
                    totCOL=totWidth;
                }
            }
            iTop+=lineheihgt;
            pPdfPainter->drawLine(QPointF(0, iTop), QPointF(pPdfWriter->width(), iTop) ); //表格横线
            if (iTop+lineheihgt>iContentheight){
                QTextOption ita; //ita为单元格的对齐方式
                ita.setAlignment(Qt::AlignRight | Qt::AlignVCenter);
                ita.setWrapMode(QTextOption::WordWrap);
                str=PageEnd;
                str+= "   第";
                str+= QString("%1").arg(PageNo, 3);
                str+=" 页";
                str+= "   共";
                str+= QString("%1").arg(PageCount, 3);
                str+=" 页";
                PageNo++;
                pPdfPainter->drawText(QRect(0, iTop, iContentWidth, 90),str, ita); //打印页脚+

                pPdfWriter->newPage();//开启新页
                iTop=0;
                font.setFamily("新宋体");
                int fontSize = 18;
                font.setPointSize(fontSize);
                pPdfPainter->setFont(font);                    // 为绘制工具设置字体
                QString str="";
                str=Title;
                pPdfPainter->drawText(QRect(0, iTop, iContentWidth, 90),str, option); //打印标题
                iTop += 90;
                str=Title1; //副标题
                fontSize = 7;
                font.setPointSize(fontSize);
                pPdfPainter->setFont(font);
                ita.setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
                pPdfPainter->drawText(QRect(0, iTop, iContentWidth, 45),str, ita); //打印副标题
                iTop += 50;

                pPdfPainter->setPen(QPen(Qt::black, 2)); //设置颜色和粗细
                // 绘制直线
                pPdfPainter->drawLine(QPointF(0, iTop), QPointF(pPdfWriter->width(), iTop) ); //表格横线
                pPdfPainter->drawLine(QPointF(0, iTop), QPointF(0, iTop+lineheihgt) );//第一根竖线
                pPdfPainter->drawLine(QPointF(pPdfWriter->width(), iTop), QPointF(pPdfWriter->width(), iTop+lineheihgt) );//最后一根竖线
                //列出表头
                totCOL=0;
                for(int j=0; j<cols; j++){

                    QTextOption ita; //ita为单元格的对齐方式
                    ita.setAlignment(Qt::AlignCenter | Qt::AlignVCenter);
                    ita.setWrapMode(QTextOption::WordWrap);
                    pPdfPainter->drawText(QRect(totCOL+2, iTop, tableWidget->columnWidth(j)*ColBL-2, lineheihgt),tableWidget->horizontalHeaderItem(j)->text(),ita);
                    pPdfPainter->drawLine(QPointF(totCOL, iTop), QPointF(totCOL, iTop+lineheihgt) );//竖线
                    totCOL+=tableWidget->columnWidth(j)*ColBL;
                    if (totWidth<totCOL){
                        totCOL=totWidth;
                    }
                }
                iTop+=lineheihgt;
            }
        }

        //自动填充空行
        while (iTop+lineheihgt<iContentheight)
        {
            pPdfPainter->drawLine(QPointF(0, iTop), QPointF(pPdfWriter->width(), iTop) ); //表格横线
            pPdfPainter->drawLine(QPointF(0, iTop), QPointF(0, iTop+lineheihgt) );//第一根竖线
            pPdfPainter->drawLine(QPointF(pPdfWriter->width(), iTop), QPointF(pPdfWriter->width(), iTop+lineheihgt) );//最后一根竖线
            totCOL=0;
            for(int j=0; j<cols; j++){
                totCOL+=tableWidget->columnWidth(j)*ColBL;
                if (totWidth<totCOL){
                    totCOL=totWidth;
                }
                pPdfPainter->drawLine(QPointF(totCOL, iTop), QPointF(totCOL, iTop+lineheihgt) );//竖线
            }
            iTop+=lineheihgt;
            pPdfPainter->drawLine(QPointF(0, iTop), QPointF(pPdfWriter->width(), iTop) ); //表格横线
        }
        str=PageEnd;
        ita.setAlignment(Qt::AlignLeft| Qt::AlignVCenter); //页尾标签左对齐
        ita.setWrapMode(QTextOption::WordWrap);
        pPdfPainter->drawText(QRect(0, iTop, iContentWidth, 90),str, ita); //打印页尾标签左对齐
        //QTextOption ita; //ita为单元格的对齐方式

        ita.setAlignment(Qt::AlignRight | Qt::AlignVCenter);
        ita.setWrapMode(QTextOption::WordWrap);
        str= "第";
        str+= QString("%1").arg(PageNo, 3);
        str+=" 页";
        str+= "   共";
        str+= QString("%1").arg(PageCount, 3);
        str+=" 页";
        pPdfPainter->drawText(QRect(0, iTop, iContentWidth, 90),str, ita); //打印页码 右对齐

    //pPdfWriter->newPage();//开启新页
    pPdfPainter->setPen(QColor(0, 0, 0));
    delete pPdfPainter;
    delete pPdfWriter;
    pdfFile.close();
    //QMessageBox::warning(this,"警告",fileName);
    QDesktopServices::openUrl(QUrl::fromLocalFile(fileName)); //根据你电脑默认的PDF打开方式 直接打开PDF文件 需要安装阅读器
    return true;
}

bool JCode::FZTableWidget(const QTableWidget *tableWidget)
{

    int rows=tableWidget->rowCount();
    int column=tableWidget->columnCount();
    QString str="";
    for (int i=0; i<column; i++){
        //ui->TableWidget->horizontalHeaderItem(0)->text();//获取表头第1行第1列的内容
        str+=tableWidget->horizontalHeaderItem(i)->text();
        str+="\t";
    }
    str+="\n";
    for(int i=0; i<rows; i++) // 取出每个格子的内容
    {
        for(int j=0; j<column; j++){
            if(tableWidget->item(i,j) != NULL){//一定要先判断非空，否则会报错
                str+=tableWidget->item(i,j)->text();
                str+="\t";
            }else{
                str+=""; //空字符弄成空格
                str+="\t";
            }
        }
        str+="\n";
    }
    QClipboard *board = QApplication::clipboard();
    board->setText(str);
    QMessageBox::information(NULL, "信息", "复制成功！");
    return true;
}
//读取文本文件
QString JCode::OpenText(const QString &aFileName)
{ //用 QTextStream打开文本文件
    QString str="";
    QFile aFile(aFileName);
    if (!aFile.exists()) //文件不存在
        return "";
    if (!aFile.open(QIODevice::ReadOnly | QIODevice::Text))
        return "";
    QTextStream aStream(&aFile); //用文本流读取文件
    aStream.setAutoDetectUnicode(true); //自动检测Unicode,才能正常显示文档内的汉字
    while (!aStream.atEnd())
    {
        str+=aStream.readLine();//读取文件的一行
        str+="\n";
    }
    aFile.close();//关闭文件
    return  str;
}
//写入一个文本文件
bool JCode::SaveText(const QString &aFileName,QString str)
{//用QTextStream保存文本文件
    QFile aFile(aFileName);
    if (!aFile.open(QIODevice::WriteOnly | QIODevice::Text))
        return false;
    QTextStream aStream(&aFile); //用文本流读取文件
    //QString str=ui->textEditStream->toPlainText(); //转换为字符串
    aStream<<str; //写入文本流
    aFile.close();//关闭文件
    return  true;
}
// QString >> QJson
QJsonObject JCode::QStringTOQJson(const QString jsonString){
    QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonString.toLocal8Bit().data());
    if( jsonDocument.isNull() ){
        qDebug()<< "===> please check the string "<< jsonString.toLocal8Bit().data();
    }
    QJsonObject jsonObject = jsonDocument.object();
    return jsonObject;
}
// QJson >> QString
QString JCode::QJsonTOQString(const QJsonObject& jsonObject){
    return QString(QJsonDocument(jsonObject).toJson());
}

bool JCode::clearTempFiles(QString FilePath)
{
    QDir Dir(FilePath);
    if(Dir.isEmpty())
    {
        qDebug() << "临时文件文件夹" << FilePath << "为空";
        return false;
    }else{
        // 第三个参数是QDir的过滤参数，这三个表示收集所有文件和目录，且不包含"."和".."目录。
        // 因为只需要遍历第一层即可，所以第四个参数填QDirIterator::NoIteratorFlags
        QDirIterator DirsIterator(FilePath, QDir::Files | QDir::AllDirs | QDir::NoDotAndDotDot, QDirIterator::NoIteratorFlags);
        while(DirsIterator.hasNext())
        {
            if (!Dir.remove(DirsIterator.next())) // 删除文件操作如果返回否，那它就是目录
            {
                QDir(DirsIterator.filePath()).removeRecursively(); // 删除目录本身以及它下属所有的文件及目录
            }
        }
        return true;
    }
}
QImage JCode::PICconvert_BW(QImage sPIC)
{ //转黑白图片
   QImage outPIC;
   QSize sizeImage = sPIC.size();
    int width = sizeImage.width(), height = sizeImage.height();
    QRgb color;
    for (int f1=0; f1<width; f1++) {
        for (int f2=0; f2<height; f2++) {
            color = sPIC.pixel(f1, f2);
            int gray = (qRed(color) + qGreen(color) + qBlue(color))/3;
            outPIC.setPixel(f1, f2, qRgb(gray, gray, gray));
        }
    }
    return outPIC;
}
QImage JCode::PIC_NoBlack(QImage sPIC,int Rotate)

{ //去黑边 Rotate未旋转角度
    QImage outPIC;
    QSize sizeImage = sPIC.size();
    int width = sizeImage.width(), height = sizeImage.height();
    //改成取四点坐标 左上（X1,Y1）  右下（X2,Y2）
    int x1=0,y1=0;
    int w=width,h=height;
    bool fp=false;
    //取x1值
    for (int x=0; x<width; x++) {
        int B=0;
        int W=0;

        for (int y=0; y<height; y++) {
            QRgb C = sPIC.pixel(x, y);
            int gray = (qRed(C) + qGreen(C) + qBlue(C))/3;
            if(gray>127){
                gray=255;
                W++;
            }else{
                gray=0;
                B++;
            }
        }
        if(B/(B+W)<0.999) {
            fp=true;
        }else{
            if(fp==false){
               x1=x;
            }
            w--;
        }
    }
    fp=false;
    //取y1值
    for (int y=0; y<height; y++) {
        int B=0;
        int W=0;

        for (int x=0; x<width; x++) {
            QRgb C = sPIC.pixel(x, y);
            int gray = (qRed(C) + qGreen(C) + qBlue(C))/3;
            if(gray>127){
                gray=255;
                W++;
            }else{
                gray=0;
                B++;
            }
        }
        if(B/(B+W)<0.999) {
            fp=true;
        }else{
            if(fp==false) {
                y1=y;
            }
            h--;
        }
    }

   outPIC=sPIC.copy(x1,y1,w,h);
   QMatrix matrix;
   matrix.rotate(Rotate);
   outPIC=outPIC.transformed(matrix);
    return outPIC;
}

// 加解密都用此方法
QString JCode::toXOR(QString src, const QChar key)
{
    for(int i = 0; i < src.count(); i++) {
        src[i] = src.at(i).toLatin1() ^ key.toLatin1();
    }
    return src;
}
QString JCode::toUp(QString src)
{
    for(int i = 0; i < src.count(); i++) {
        QChar curC = src.at(i);
        if(curC.isUpper()) {
            curC = curC.toLower();
        } else if(curC.isLower()){
            curC = curC.toUpper();
        }
        src[i] = curC;
    }
    return src;
}
/*判断文件是否存在*/
bool JCode::isFileExist(QString fullFileName)
{
    QFileInfo fileInfo(fullFileName);
    if(fileInfo.isFile())
    {
        return true;
    }
    return false;
}

 QString JCode::toChineseBIG(const double &Fnumber,QString unit)
{
//转中文大写数字，unit 是单位： 元 公斤 吨 等等！
    if(qAbs(Fnumber)<0.01)   //保留2位小数时，近似看作零的情况
        return "零";
    //判断正负号
    QString numberSign;//存储符号
    if(Fnumber<0)
        numberSign = "（负数）";
   //将数据的绝对值 转换成字符串，如-58 转成 “58.00”
   QString number = QString::number(qAbs(Fnumber),'f',2);//qAbs绝对值 ，保留两位小数
   QString Left_of_Point;//整数部分
   int length =number.length()-3;//整数部分的长度，（精确度为2，去除小数和小数点）
   if(length>12)
   {
        //qDebug()<<"输入的数值超过范围！"
        return "输入的数值超过范围！";
   }
   QStringList numerical_unit   =   {"","拾","佰","仟","万","拾", "佰", "仟", "亿", "拾", "佰", "仟"};
   QStringList numerical_value  =   {"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};

   //数数整数低位多少个连零
   int counter_0=0;
   for(int i =length-1;i>=0;i--)
   {
       if((number[i].toLatin1()-'0' )==0) //从个位开始，向高位走
           counter_0++;
       else
           break;
   }
   if(length==1 && counter_0==1) //0.x
       counter_0=0; //不进行过滤
   for(int i=0,flag=1;i<length-counter_0;i++)
   {
       if((number[i].toLatin1()-'0')==0)
       {
           if((flag!=0 && (length-1-i)%4 != 0) || length ==1) //flag！=0  表示前一个数值 不为0
           Left_of_Point+="零"; //后面不用添加 单位
           if((length-1-i)%4 == 0) //如果0处于分段处，后面需添加单位
           Left_of_Point+=numerical_unit[length-1-i];//添加数值单位
           flag =0; //标记
       }
       else
       {
        flag =1;
        Left_of_Point+=numerical_value[number[i].toLatin1()-'0']; //'5'-'0'==5
        Left_of_Point+=numerical_unit[length-1-i];//添加数值单位
       }
   }
    //QString Right_of_Point;//小数点右侧，小数部分(保留两位)  xxxx.yy
    int totalLength = number.length();
    if(number[totalLength-2]=='0'&&number[totalLength-1]=='0')
    {
        QString Bigcn=numberSign+Left_of_Point+unit;
        return Bigcn;
    }
    else if(number[totalLength-2]!='0'&&number[totalLength-1]=='0')
    {
        QString Bigcn=numberSign+Left_of_Point+"点"+numerical_value[number[totalLength-2].toLatin1()-'0']+unit;
        return Bigcn;
    }
    else
    {
        QString Bigcn=numberSign+Left_of_Point+"点"+numerical_value[number[totalLength-2].toLatin1()-'0']+numerical_value[number[totalLength-1].toLatin1()-'0']+unit;
        return Bigcn;
    }
    return "异常情况";
}
